package cn.iocoder.yudao.module.system.controller.app.tradinghours;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.system.controller.admin.tradinghours.vo.SystemTradingHoursListReqVO;
import cn.iocoder.yudao.module.system.controller.admin.tradinghours.vo.SystemTradingHoursRespVO;
import cn.iocoder.yudao.module.system.service.tradinghours.SystemTradingHoursService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.annotation.security.PermitAll;
import jakarta.validation.Valid;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 营业时间")
@RestController
@RequestMapping("/system/trading-hours")
@Validated
public class AppSystemTradingHoursController {

    @Resource
    private SystemTradingHoursService tradingHoursService;
    
    @PostMapping("/list")
    @Operation(summary = "获取营业时间列表")
    @PermitAll
    public CommonResult<List<SystemTradingHoursRespVO>> getTradingHoursList(@Valid @RequestBody SystemTradingHoursListReqVO reqVO) {
        List<SystemTradingHoursRespVO> list = tradingHoursService.getTradingHoursList(
                reqVO.getType(), reqVO.getModule(), reqVO.getStartDate(), reqVO.getEndDate());
        return success(list);
    }

}